package main

import (
	"fmt"
	"reflect"
	"time"
)

func main() {
	ch1 := make(chan int)
	ch2 := make(chan int)

	go func(a ...chan int) {
		var cases []reflect.SelectCase

		for _, v := range a { // 创建接收cases
			cases = append(cases, reflect.SelectCase{
				Chan: reflect.ValueOf(v),
				Dir:  reflect.SelectRecv,
			})
		}

		for {
			chosen, recv, recvOK := reflect.Select(cases)
			fmt.Println(chosen, recv, recvOK)
		}

	}(ch1, ch2)

	for i := 0; true; i++ {
		if i%2 == 0 {
			ch1 <- i
		} else {
			ch2 <- i * 10000
		}
		time.Sleep(time.Millisecond * 200)

	}

}



